package com.sense.kukoo.common.repo.http

import com.sense.kukoo.common.repo.bean.*
import com.sense.kukoo.common.repo.http.bean.*
import okhttp3.MultipartBody
import okhttp3.RequestBody
import retrofit2.http.*

interface KukooHttpApi {

    /**首页配置查询 */
    @GET("/api/resource/index/module")
    suspend fun indexModule(): ResultBean<List<ModuleBean>>

    /**首页内容列表查询 */
    @GET("/api/resource/index/contents/{pageIndex}/{pageSize}/{moduleId}")
    suspend fun indexContent(
        @Path("pageIndex") pageIndex: String,
        @Path("pageSize") pageSize: String,
        @Path("moduleId") moduleId: String,
        ): ResultBean<List<IndexContentBean>>

    /**获取热词 */
    @GET("/api/resource/hotWord/list")
    suspend fun hotWordList(): ResultBean<List<String>>

    /**用户查询 (个人中心)*/
    @GET("/api/resource/content/userSearch/{pageIndex}/{pageSize}/{userId}")
    suspend fun userSearchById(
        @Path("pageIndex") pageIndex: String,
        @Path("pageSize") pageSize: String,
        @Path("userId") userId: String,
    ): ResultBean<List<IndexContentBean>>

    /**关键字查询用户 */
    @GET("/api/user/search/{pageIndex}/{pageSize}/{keyword}")
    suspend fun userSearchByKeyword(
        @Path("pageIndex") pageIndex: String,
        @Path("pageSize") pageSize: String,
        @Path("keyword") keyword: String,
    ): ResultBean<List<UserSearchBean>>

    /**关键字查询内容 */
    @GET("/api/resource/content/keywordSearch/{pageIndex}/{pageSize}/{keyword}")
    suspend fun keywordSearch(
        @Path("pageIndex") pageIndex: String,
        @Path("pageSize") pageSize: String,
        @Path("keyword") keyword: String,
    ): ResultBean<List<IndexContentBean>>

    /**发送验证码*/
    @POST("/api/user/send-verify-code")
    suspend fun sendVerifyCode(@Body requestBody: RequestBody): ResultBean<Boolean>

    /**查询用户信息*/
    @GET("/api/user/info/{userId}")
    suspend fun getUserInfo(@Path("userId") userId: String): ResultBean<UserInfoBean>

    /**关注(粉丝)列表-分页*/
    @POST("/api/user/subscription/page")
    suspend fun userSubscriptionPage(@Body requestBody: RequestBody): ResultBean<List<UserSearchBean>>

    /**关注列表-内容查询*/
    @GET("/api/resource/content/followSearch/{pageIndex}/{pageSize}")
    suspend fun followSearch(
        @Path("pageIndex") pageIndex: String,
        @Path("pageSize") pageSize: String,
    ): ResultBean<List<IndexContentBean>>

    /**关注列表(最多返回20条)*/
    @GET("/api/user/subscription/listUser")
    suspend fun followListUser(): ResultBean<List<UserSearchBean>>

    /**上报收听进度 */
    @POST("/api/user/listen/save")
    suspend fun saveListen(@Body requestBody: RequestBody): ResultBean<Boolean>

    /**订阅-取消*/
    @POST("/api/user/subscription/sub/{contentUserId}")
    suspend fun subscription(@Path("contentUserId") contentUserId: String): ResultBean<Boolean>

    /**是否订阅  */
    @GET("/api/user/subscription/is-subscription/{contentUserId}")
    suspend fun isSubscription(@Path("contentUserId") contentUserId: String): ResultBean<Boolean>

    /**点赞-取消*/
    @POST("/api/user/like/{contentId}/{contentUserId}")
    suspend fun like(
        @Path("contentId") contentId: String,
        @Path("contentUserId") contentUserId: String,
    ): ResultBean<Boolean>

    /**是否点赞   */
    @GET("/api/user/like/is-like/{contentId}")
    suspend fun isLike(@Path("contentId") contentId: String): ResultBean<Boolean>

    /** 上传图片*/
    @Multipart
    @POST("/api/user/file/upload")
    suspend fun uploadPic(@PartMap params: Map<String, @JvmSuppressWildcards Any>, @Part file: MultipartBody.Part
    ): ResultBean<String>

    /**反馈*/
    @POST("/api/user/edit")
    suspend fun edit(@Body requestBody: RequestBody): ResultBean<Boolean>

    /**内容详情*/
    @GET("/api/resource/content/info/{id}")
    suspend fun contentInfo(@Path("id") id: String): ResultBean<ContentInfoBean>

    /**内容详情页-正在收听数据*/
    @GET("/api/user/listen/listening/{contentId}")
    suspend fun contentListening(@Path("contentId") contentId: String): ResultBean<ContentListeningBean>

    /**获取评论记录*/
    @POST("/api/user/comment/list")
    suspend fun commentList(@Body requestBody: RequestBody): ResultBean<ArrayList<CommentRecordBean>>

    /**保存评论记录*/
    @POST("/api/user/comment/save")
    suspend fun commentSave(@Body requestBody: RequestBody): ResultBean<CommentRecordBean>

    /**删除评论记录*/
    @POST("/api/user/comment/remove/{id}")
    suspend fun commentRemove(@Path("id") id: String): ResultBean<Boolean>

    /**分享成功*/
    @POST("/api/resource/content/share/{id}")
    suspend fun shareSuccess(@Path("id") id: String): ResultBean<Boolean>

    /**message 小红点数量*/
    @GET("/api/user/message/getCount")
    suspend fun messageCount(): ResultBean<UserMessagesBean>

    /**获取点赞消息列表*/
    @POST("/api/user/message/page/like")
    suspend fun messageLikes(@Body requestBody: RequestBody): ResultBean<ArrayList<UserMessageLikeBean>>

    /**获取关注消息列表*/
    @POST("/api/user/message/page/sub")
    suspend fun messageFollowers(@Body requestBody: RequestBody): ResultBean<ArrayList<UserMessageFollowersBean>>

    /**获取评论消息列表*/
    @POST("/api/user/message/page/comment")
    suspend fun messageComments(@Body requestBody: RequestBody): ResultBean<ArrayList<UserMessageCommentsBean>>

    /**获取系统消息列表(type 必传)*/
    @POST("/api/user/message/page/system")
    suspend fun messageSystems(@Body requestBody: RequestBody): ResultBean<ArrayList<UserMessageSystemBean>>

    /**删除消息*/
    @POST("/api/user/message/del")
    suspend fun messageDelete(@Body requestBody: RequestBody): ResultBean<Boolean>

    /**清除小红点*/
    @POST("/api/user/message/clean")
    suspend fun messageReddotClean(@Body requestBody: RequestBody): ResultBean<Boolean>

    /**fcm 注册(登录后调用)*/
    @POST("/api/user/push/register")
    suspend fun registerPush(@Body requestBody: RequestBody): ResultBean<Boolean>

    /**收听历史 - 分页查询*/
    @POST("/api/user/listen/query-page/{pageIndex}/{pageSize}")
    suspend fun listenPage(
        @Path("pageIndex") pageIndex: String,
        @Path("pageSize") pageSize: String,
    ): ResultBean<List<ListenRecordBean>>

    /**收听历史 - 删除*/
    @POST("/api/user/listen/delete")
    suspend fun listenDelete(@Body requestBody: RequestBody): ResultBean<Boolean>

    /**收听历史 - 清空*/
    @POST("/api/user/listen/clean")
    suspend fun listenClean(): ResultBean<Boolean>

    /**首页配置查询 */
    @GET("/api/book/app-ui-conf/index")
    suspend fun index(): ResultBean<IndexBean>

    /**首页推荐栏数据查询 */
    @GET("/api/book/recommend/{code}")
    suspend fun recommend(@Path("code") code: String): ResultBean<List<RecommendBean>>

    /**推荐频道: code 其它频道: 二级分类ID*/
    @GET("/api/book/more/{pageIndex}/{pageSize}/{code}")
    suspend fun more(
        @Path("pageIndex") pageIndex: String,
        @Path("pageSize") pageSize: String,
        @Path("code") code: String
    ): ResultBean<QueryPageBean<BookBean>>

    /**搜索推荐*/
    @POST("/api/user/search/app/query-page/{pageIndex}/{pageSize}")
    suspend fun searchQueryPage(
        @Path("pageIndex") pageIndex: String,
        @Path("pageSize") pageSize: String
    ): ResultBean<QueryPageBean<SearchRecordBean>>

    /**搜索推荐*/
    @POST("/api/book/hot-word/query-page")
    suspend fun hotWordQueryPage(@Body requestBody: RequestBody): ResultBean<QueryPageBean<HotWordBean>>

    /**搜索*/
    @POST("/api/book/search")
    suspend fun searchBook(@Body requestBody: RequestBody): ResultBean<QueryPageBean<BookBean>>

    /**收听记录分页查询*/
    @POST("/api/book/library/listen/app/query-page/{pageIndex}/{pageSize}")
    suspend fun listenQueryPage(
        @Path("pageIndex") pageIndex: String,
        @Path("pageSize") pageSize: String
    ): ResultBean<QueryPageBean<LibraryListenBean>>

    /**订阅记录分页查询*/
    @POST("/api/book/library/subscription/app/query-page/{pageIndex}/{pageSize}")
    suspend fun subscriptionQueryPage(
        @Path("pageIndex") pageIndex: String,
        @Path("pageSize") pageSize: String
    ): ResultBean<QueryPageBean<LibrarySubscriptionBean>>

    /**订阅单集更新分页查询*/
    @POST("/api/book/library/subscription/app/query-item-page/{pageIndex}/{pageSize}")
    suspend fun subscriptionQueryItemPage(
        @Path("pageIndex") pageIndex: String,
        @Path("pageSize") pageSize: String
    ): ResultBean<QueryPageBean<BookItemBean>>

    //默认携带40条章节数据,若想继续加载则需调整分页起始位置(eg: pageSize = 20, pageIndex = 3 (40 / 20 + 1))
    /**详情*/
    @GET("/api/book/details/{id}")
    suspend fun bookDetails(@Path("id") id: String): ResultBean<BookDetailsBean>

    /**取消小红点*/
    @POST("/api/user/subscription/lightOff/{id}")
    suspend fun lightOff(@Path("id") id: String): ResultBean<Boolean>

    /**首页推荐栏数据查询 */
    @GET("/api/book/recommend")
    suspend fun recommend(): ResultBean<List<RecommendBean>>

    //首页配置navMenus中的code[编码] 等同于 firstTypeId[一级分类ID]
    /**导航栏页面数据查询*/
    @GET("/api/book/navigation/{firstTypeId}")
    suspend fun navigation(@Path("firstTypeId") firstTypeId: String): ResultBean<List<NavigationBean>>

    /**登录*/
    @POST("/api/user/login")
    suspend fun login(@Body requestBody: RequestBody): ResultBean<LoginResultBean>

    /**第三方登录*/
    //source : 用户来源: 0. 内部; 1. facebook; 2. google; 3.apple; 4.twitter; 5. line;
    @POST("/api/user/third-login")
    suspend fun thirdLogin(@Body requestBody: RequestBody): ResultBean<LoginResultBean>

    /**反馈*/
    @POST("/api/user/feedback/save")
    suspend fun feedback(@Body requestBody: RequestBody): ResultBean<Boolean>

    /**删除账号*/
    @POST("/api/user/remove")
    suspend fun remove(): ResultBean<Any>

    /**详情页-分页查询*/
    @POST("/api/book/item/query-page")
    suspend fun bookQueryPage(@Body requestBody: RequestBody): ResultBean<QueryPageBean<BookItemBean>>

    /**举报*/
    @POST("/api/book/report/save")
    suspend fun report(@Body requestBody: RequestBody): ResultBean<Boolean>

    /**是否点赞*/
    @GET("/api/user/like/is-like/{bookId}/{bookItemId}")
    suspend fun isLike(@Path("bookId") bookId: String, @Path("bookItemId") bookItemId: String): ResultBean<Boolean>

}